package UDP;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class Receive {
    public static void main(String[] args) throws IOException {
        System.out.println("服务器启动");
        DatagramSocket ds=new DatagramSocket(8080);
        DatagramPacket dp=new DatagramPacket(new byte[1024],1024);
        ds.receive(dp);
        String data=new String(dp.getData(),0,dp.getLength());
        System.out.println("对方说："+data);
        String ip=dp.getAddress().getHostAddress();
        int port=dp.getPort();
        System.out.println("对方ip： "+ip+" "+"对方端口："+port);
        ds.close();
    }
}
